package tcpnetwork;

import java.io.IOException;
import java.util.HashMap;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 */
public class TcpDictServer extends TcpEchoServer{

    private HashMap<String, String> dictionary;


    public TcpDictServer(int port) throws IOException {
        super(port);
        dictionary = new HashMap<>();
        dictionary.put("cat", "小猫");
        dictionary.put("dog", "小狗");
        dictionary.put("air", "空气");
    }

    @Override
    public String process(String request) {
        return dictionary.getOrDefault(request, "无法翻译");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer tcpDictServer = new TcpDictServer(9090);
        tcpDictServer.start();
    }
}
